package cn.itcast.contorller;

import cn.itcast.domain.Accounts;
import cn.itcast.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.annotation.WebServlet;
import java.util.List;

@Controller

public class AccountContorller {
        @Autowired
        private AccountService accountService;
//    @RequestMapping("/find")
//    @ResponseBody
//    public ModelAndView findById(ModelAndView modelAndView,String name)throws Exception{
//        Accounts byName = accountService.findByName(name);
//        System.out.println(byName);
//        modelAndView.addObject("id",byName);
//        modelAndView.setViewName("account.html");
//        return modelAndView;
//    }
    @RequestMapping("/find")
    @ResponseBody
    public List<Accounts> findById(String name)throws Exception{
        List<Accounts> byName = accountService.findByName(name);
        return byName;
    }



}
